<header id="topbar">
    <div class="topbar-left">
        <ol class="breadcrumb">
            <li class="crumb-active">
                <a href="#op/transaction/">交易流水查询</a>
            </li>
        </ol>
    </div>
    <div class="topbar-right">
        <div class="ml15 ib va-m" id="toggle_sidemenu_r">
            <a href="#" class="pl5"> <i class="fa fa-sign-in fs22 text-primary"></i>
            </a>
        </div>
    </div>
</header>

<section id="content" class="animated fadeIn">
    <% if(items.length > 0){ %>
        <div class="panel overflow">
            <table class="table table-striped fs13" id="main-list">
                <thead>
                    <tr class="bg-light">
                        <th class="sortable" data-field="created_at">时间</th>
                        <th>种类</th>
                        <th>交易类型</th>
                        <th class="sortable" data-field="price">金额</th>
                        <th>状态</th>
                        <th>用户余额</th>
                        <th>订单编号</th>
                        <th>充值编号</th>
                    </tr>
                </thead>
                <tbody class="admin-form">
                    <%  var buyAmount = 0;
                        _.each(items, function(item){
                        buyAmount += parseFloat(item.price);
                        if(item.coupon) buyAmount += parseFloat(item.coupon);
                    %>
                        <tr data-id="<%= item.id %>" >
                            <td><%= item.created_at %></td>
                            <% if(item.price>0){%>
                            <td>收入</td>
                            <%}else{ %>
                            <td>支出</td>
                            <%}%>
                            <td><%= item.title %></td>
                            <% if(item.coupon){%>
                            <td><%= item.price %> (红包+<%= item.coupon %>)</td>
                            <%}else{ %>
                            <td><%= item.price %></td>
                            <%}%>
                            <td><%= TRANSACTION_STATUS[item.status] %></td>
                            <td><%= item.balance %></td>
                            <% if(item.order_id){%>
                                <td><a class="modify-item"><%= item.order_id %></a></td>
                            <%} else {%>
                            <td>-</td>
                            <% } %>
                            <td><%= item.pay_id || '-' %></td>
                        </tr>
                    <% }) %>
                </tbody>
            </table>
        </div>
        <div><div class="pull-left" id="page-tips"></div>
        <span style="margin-left:20px;">本页累计盈亏金额：</span><span style="color:#F00"><%= (buyAmount || 0).toFixed(3) %></span>
        <span style="margin-left:20px;">总收入金额：</span><span style="color:#F00"><%= (total_income || 0) %></span>
        <span style="margin-left:20px;">总支出金额：</span><span style="color:#F00"><%= (total_outcome || 0) %></span>
        <div id="paginator"></div>
    </div>
        <% }else{ %>
        <h4 class="text-muted">请从右侧进行搜索...</h4>
        <% } %>
</section>

<!-- Panel popup -->
<div id="editWithdrawPanel" class="popup-basic popup-lg bg-none mfp-with-anim mfp-hide">
    <div class="panel">
        <div class="panel-heading">
            <span class="panel-icon"><i class="fa fa-pencil"></i></span>
            <span class="panel-title">订单详情</span>
        </div>
        <div class="panel-body">
            <form id="behavior-form" class="form-horizontal" role="form">
            <div class="form-group">
                <label for="order_id" class="col-md-3 control-label">订单id：</label>
                <div class="col-md-9">
                    <p class="form-control-static text-muted" id="order_id">
                    </p>
                </div>
            </div>
            <div class="form-group">
                <label for="user_id" class="col-md-3 control-label">用户编号：</label>
                <div class="col-md-9">
                    <p class="form-control-static text-muted" id="user_id">
                    </p>
                </div>
            </div>
            <div class="form-group">
                <label for="activity_type" class="col-md-3 control-label">彩种：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-muted" id="activity_type">
                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="bet_name" class="col-md-3 control-label">玩法：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-muted" id="bet_name">
                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="term" class="col-md-3 control-label">期号：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-muted" id="term">
                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="number" class="col-md-3 control-label">购买号码：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-muted" id="number">

                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="price" class="col-md-3 control-label">购买金额：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-muted" id="price">

                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="win_price" class="col-md-3 control-label">中奖金额：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-danger" id="win_price">

                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="bonus" class="col-md-3 control-label">加奖金额：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-danger" id="bonus">

                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="orderStatus" class="col-md-3 control-label">状态：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-muted" id="orderStatus">
                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="created_at" class="col-md-3 control-label">购买时间：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-muted" id="created_at">
                  </p>
                </div>
            </div>
            <div class="form-group">
                <label for="updated_at" class="col-md-3 control-label">最后更新时间：</label>
                <div class="col-md-9">
                  <p class="form-control-static text-muted" id="updated_at">
                  </p>
                </div>
            </div>
            </form>
        </div>
        <div class="panel-footer text-right">
            <button class="btn btn-primary" type="button" id="submitClose">关闭</button>
        </div>
    </div>
</div>

<aside id="sidebar_right" class="nano">
    <div class="p20 admin-form">
        <h4 class="mt5 text-muted fw500">过滤条件：</h4>
        <hr class="short">
        <div class="section mb15">
            <label class="field prepend-icon">
                <input title="用户ID" type="text" id="searchUserID" class="gui-input" data-field="searchUserID" placeholder="用户ID" value="<%= searched.user_id %>" >
                <label class="field-icon"><i class="fa fa-tag"></i></label>
            </label>
        </div>
        <h6 class="fw400">收支条件</h6>
        <div class="section mb15">
            <label for="searchType" class="field select">
                <select id="searchType" name="searchType" data-field="type">
                    <option value="0" <%= searched.selectedType == 0 ? 'selected' : '' %>>所有</option>
                    <option value="1" <%= searched.selectedType == 1 ? 'selected' : '' %>>收入</option>
                    <option value="-1" <%= searched.selectedType == -1 ? 'selected' : '' %>>支出</option>
                </select>
                <i class="arrow"></i>
            </label>
        </div>
        <h6 class="fw400">交易类型
        </h6>
        <div class="section mb15">
            <select id="searchTitle" name="searchTitle" data-field="title" multiple>
                <!--<option value="-1" <%= searched.title == -1 ? 'selected' : '' %>>所有</option>-->
                <% _.each(TRANSACTION_TITLE, function(key,value){
                    if(searched.title){
                        if(key.constructor === Array) var key_str = key.join(',');
                        else var key_str = key %>
                    <option value='<%=key%>'<%= searched.title.includes(key_str)? 'selected': ''%>><%= value%></option>
                    <%}else{%>
                    <option value='<%=key%>'><%= value%></option>
                <%}})%>
            </select>
            <i class="arrow double"></i>
        </div>
        <h6 class="fw400">下单时间</h6>
        <div class="section row">
            <div class="col-md-6">
                <input type="text" title="下限，包含当天" name="searchCreatedAtLower" id="searchCreatedAtLower" class="gui-input" data-type="date" value="<%= searched.created_at_lower %>" placeholder=">=">
            </div>
            <div class="col-md-6">
                <input type="text" title="上限，不包括当天" name="searchCreatedAtUpper" id="searchCreatedAtUpper" class="gui-input" data-type="date" value="<%= searched.created_at_upper %>" placeholder="<">
            </div>
        </div>
        <hr class="short">
        <button class="btn btn-default btn-block" type="button" id="search">搜索</button>
    </div>
</aside>